<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!--{include file='comm/header.tpl'}-->
    <title>添加资源位</title>
    <style type="text/css">
        div.items2 tr {height: 50px;}
    </style>
    <link rel="stylesheet" href="/framework/uploadify/uploadify.css" type="text/css" media="screen" />
    <script language="JavaScript" src="/framework/uploadify/jquery.uploadify.min.js" type="text/javascript"></script>
</head>
<body>
<div style="width:100%">

    <div class="items clearfix">
        <h2 style="" class="tal">正在操作：添加资源位</h2>
        <div class="items2">

            <!--{if !$source_category_array}-->

            <div class="error-box">
                <!--{$error_msg}-->
            </div>

            <!--{else}-->

            <div class="select-box" id="select_box">
                <div class="selected" selectid="1">商品资源位</div>
                <div selectid="2">图片资源位</div>
            </div>

            <div class="content-box">
                <form id="source_form" onsubmit="return false;">
                    <table>
                        <tbody>
                        <tr>
                            <td class="tar" width="150">资源位分类：</td>
                            <td width="400">
                                <select id="parnet_id" name="parnet_id">
                                    <!--{foreach from=$source_category_array item=source}-->
                                        <!--{if $source->parent_category_id == 0}-->
                                            <option value="<!--{$source->source_category_id}-->" disabled="disabled"><!--{$source->source_category_title}--></option>
                                        <!--{else}-->
                                            <option value="<!--{$source->source_category_id}-->">&nbsp;&nbsp;<!--{$source->source_category_title}--></option>
                                        <!--{/if}-->
                                    <!--{/foreach}-->
                                </select>
                                <font color="red">*</font>
                            </td>
                            <td width="*" rowspan="4">
                                <div id="goods_img" style="border: 1px solid #CCCCCC;height: 200px;margin: 0 auto;width: 260px;"></div>
                            </td>
                        </tr>
                        <tr>
                            <td class="tar">商品编码：</td>
                            <td>
                                <input type="text" name="product_code" id="product_code" style="width: 100px;" /> <font color="red">*</font>
                            </td>
                        </tr>
                        <tr>
                            <td class="tar">商品名称：</td>
                            <td id="goods_name"></td>
                        </tr>
                        <tr>
                            <td class="tar">当前销售价：</td>
                            <td id="goods_price" class="red"></td>
                        </tr>
                        <tr>
                            <td class="tar">使用标志：</td>
                            <td>
                                <input type="radio" value="1" name="useFlg" /> 启用
                                <input type="radio" value="0" name="useFlg" /> 禁用
                                <font color="red">*</font>
                            </td>
                            <td class="tac">
                                <input type="button" value="上传图片" class="btn" onclick="source.uploadImg();" />
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3" class="tac"><font class="red">如果您没有上传图片，系统将默认采用商品的主图片</font></td>
                        </tr>
                        </tbody>
                    </table>
                </form>
            </div>

            <!--{/if}-->

        </div>
    </div>


    <div class="bottom_fixbox">
        <div class="rectbox tac">
            <input type="button" class="btn" onclick="source.check();" value="添加资源位分类" />&nbsp;&nbsp;&nbsp;
            <input type="button" class="btn" onclick="E.closeWindows();" value="关闭" />
        </div>
    </div>

</div>

<script type="text/javascript">
    var source = {

        check: function() {
            var dt = E.getFormValues("source_form");
            var error_msg = "";
            if (dt.index == "")
                error_msg += "分类别名不能为空<br />";
            if (dt.title == "")
                error_msg += "分类标题不能为空<br />";
            if (!E.digitalCheck(dt.sort))
                error_msg += "排序序号必须是数字<br />";

            if (error_msg != "")
                comm_alert(error_msg);
            else {
                $.ajax({
                    type: "POST",
                    url: "/quanliadmin/app/content/ajax/source.php?operFlg=2",
                    dataType: "JSON",
                    data: dt,
                    success: function( result_obj ) {
                        if (result_obj.code == 200) {
                            E.opener("source.load");
                            comm_alert(result_obj.message, 5);
                        } else {
                            comm_alert(result_obj.message);
                        }
                    }
                });
            }
        },

        uploadImg: function() {
            window.open('/quanliadmin/app/uploads/imageUpload.php?uploadPara=16','上传','height=50, width=600, top=280,left=300,toolbar=no, menubar=no, scrollbars=no,resizable=no,location=no, status=no');
        }

    };


    function getUploadFileName(upload_fileName) {
        alert(upload_fileName);
    }



    $("#select_box div").click(function() {
        var index = $(this).index();
        var id = $(this).attr("selectid");
        $("#select_box div").removeClass("selected").eq(index).addClass("selected");
        $("div.content-box").hide().eq(index).show();
    });


</script>

</body>

</html>
